package com.lichuang.dedao.city.controller;

import com.lichuang.dedao.city.util.LoadProperties;
import com.lichuang.dedao.city.util.Login;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Properties;

@RestController
@CrossOrigin("http://localhost:8020")
public class FileController {

    /**
     * 上传文件接口
     * @param source  本地地址 如 F:/access/index.txt
     * @param destination nginx路径 如、/text || /img
     * @return
     */
    @RequestMapping("/file")
    public int file(String source,String destination){
        if(source==null || source == ""){
            return -1;
        }else if (destination==null || destination ==""){
            return -1;
        }else {
            Properties properties = LoadProperties.getProperties();
            int i = (int) Login.login(properties,source,destination);
            return i;
        }

    }

}
